#ifndef LAMBERTIAN_H
#define LAMBERTIAN_H

#include<material.h>
#include<utils.h>
#include<texture.h>
class lambertian:public material
{
public:
    lambertian(texture*a):albedo(a){}
    virtual bool scatter(const ray&r_in,const hit_record&rec,QVector3D&attenuation,ray&scattered)const{
        QVector3D target=rec.p+rec.normal+random_in_unit_sphere();
        scattered=ray(rec.p,target-rec.p,r_in.time());
        float u,v;
        get_sphere_uv(rec.p,u,v);
        attenuation=albedo->value(u,v,rec.p);
        return true;
    }
    texture*albedo;
};

#endif // LAMBERTIAN_H
